package com.jiai.cloud.base.util;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 时间格式软换
 * @author Administrator
 *
 */
public class DateJsonSerializer extends JsonSerializer<Date>
{  
    public static final SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd");
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider)
            throws IOException,JsonProcessingException
    {  
        jsonGenerator.writeString(format.format(date));    
    }    
}  